package mybatis.generator.plugin.mysql;

import org.mybatis.generator.api.dom.java.FullyQualifiedJavaType;
import org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl;

import java.sql.Types;


/**
 * 自定义类型转换器，tinyint -> Integer; smallint -> Integer
 */
public class MysqlJavaTypeResolver extends JavaTypeResolverDefaultImpl {
    public MysqlJavaTypeResolver() {
        super();

        //修改SMALLINT和TINYINT映射类型
        typeMap.put(Types.SMALLINT, new JdbcTypeInformation("SMALLINT", //$NON-NLS-1$
                new FullyQualifiedJavaType(Integer.class.getName())));
        typeMap.put(Types.TINYINT, new JdbcTypeInformation("TINYINT", //$NON-NLS-1$
                new FullyQualifiedJavaType(Integer.class.getName())));
    }
}
